from po.Base.Base import Base
from selenium.webdriver.common.by import By
import time
class Page(Base):
    deng=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    def deng_click(self):
        self.click(self.deng)
    dy1=(By.XPATH,'/html/body/div[4]/div/div[1]/div[1]/span[1]')
    def dy1_text(self):
        return self.text(self.dy1)
    name=(By.NAME,'username')
    def name_keys(self):
        self.send_keys(self.name,'13811033962')
    password=(By.NAME,'password')
    def password_keys(self):
        self.send_keys(self.password,'123456')
    dengluanniu=(By.XPATH,'//*[@id="theForm"]/div[5]/a')
    def dengluanniu_click(self):
        self.click(self.dengluanniu)
    ssk=(By.XPATH,'/html/body/div[2]/div/div/form/div[1]/input')
    def ssk_keys(self):
        self.send_keys(self.ssk,'电饭煲')
    ssan=(By.XPATH,'//*[@id="searchForm"]/div[2]/input')
    def ssan_click(self):
        self.click(self.ssan)
    dy2=(By.XPATH,'/html/body/div[4]/a[2]')
    def dy2_text(self):
        return self.text(self.dy2)
    sp_loc=(By.XPATH,'//img[@src="/uploads/images/20210629/da986e0513db8d7c38daf94cd76db3b7.jpg"]')
    def sp(self):
        self.click(self.sp_loc)
    num_loc=(By.XPATH,'//*[@id="store_nums"]')
    def num(self):
        self.clear(self.num_loc)
        time.sleep(2)
        self.send_keys(self.num_loc,'2')
    add_loc=(By.XPATH,'//*[@id="add-cart"]')
    def add(self):
        self.click(self.add_loc)
    ck_loc=(By.XPATH,'/html/body/div[3]/div[3]/div[2]/a')
    def ck(self):
        self.click(self.ck_loc)
    dy3_loc=(By.XPATH,'/html/body/div[4]/div[1]/a[2]')
    def dy3(self):
        return self.text(self.dy3_loc)
    gx_loc=(By.XPATH,'//*[@id="cart-box"]/div[1]/table/tbody/tr[2]/td[1]/input')
    def gx(self):
        self.click(self.gx_loc)
    js_loc=(By.XPATH,'//*[@id="cartForm"]/div[2]/div/a[2]')
    def js(self):
        self.click(self.js_loc)
    dy4_loc=(By.XPATH,'/html/body/div[4]/div[1]/a[2]')
    def dy4(self):
        return self.text(self.dy4_loc)
    gxdz_loc=(By.XPATH,'//*[@id="address-14"]')
    def gxdz(self):
        self.click(self.gxdz_loc)
    xyb_loc=(By.XPATH,'//*[@id="order-button"]')
    def xyb(self):
        self.click(self.xyb_loc)
    ddwc_loc=(By.XPATH,'/html/body/div[4]/div[1]/a[2]')
    def ddwc(self):
        return self.text(self.ddwc_loc)
    dy5_loc=(By.XPATH,'/html/body/div[4]/div[3]/span')
    def dy5(self):
        return self.text(self.dy5_loc)
    ckdd_loc=(By.XPATH,'/html/body/div[4]/div[3]/p/a')
    def ckdd(self):
        self.click(self.ckdd_loc)
    bh_loc=(By.XPATH,'/html/body/div[5]/div[2]/div/div[2]/table[2]/tbody/tr[2]/td[2]')
    def bh(self):
        return self.text(self.bh_loc)
    fhzt_loc=(By.XPATH,'/html/body/div[5]/div[2]/div/div[2]/table[2]/tbody/tr[5]/td[2]')
    def fhzt(self):
        return self.text(self.fhzt_loc)
    def test_sousuo(self):
        self.open('http://10.59.9.12:7001/')
        time.sleep(2)
        self.deng_click()
        time.sleep(2)
        print(self.dy1_text())
        time.sleep(2)
        self.name_keys()
        self.password_keys()
        time.sleep(10)
        self.dengluanniu_click()
        time.sleep(5)
        self.ssk_keys()
        time.sleep(2)
        self.ssan_click()
        time.sleep(2)
        print(self.dy2_text())
        time.sleep(2)
        self.sp()
        time.sleep(2)
        self.num()
        self.add()
        time.sleep(2)
        self.ck()
        print(self.dy3())
        self.gx()
        self.js()
        print(self.dy4())
        self.gxdz()
        self.xyb()
        print(self.ddwc())
        time.sleep(2)
        print(self.dy5())
        self.ckdd()
        time.sleep(2)
        print(self.bh())
        time.sleep(2)
        print(self.fhzt())